import javax.swing.ImageIcon;

/**
 * Class to represent a playing card
 * @author Kat Winter
 */
public class Card implements Comparable<Card> {
	
    private final Suit suit;
    private final Face face;
    private ImageIcon cardImage;
 
    /**
     * Constructor initializes face and suit variables
     * @param face Face value of the card -> 2-14, Jack, Queen, King, or Ace
     * @param suit Suit value of the card -> Clubs, Diamonds, Hearts, or Spades
     */
    public Card(Face face, Suit suit) {
        this.face = face;
        this.suit = suit;
    }
    
    /**
     * Constructor to initialize face and suit and also the card's image
     * @param face Face value of the card -> 2-10, Jack, Queen, King, or Ace
     * @param suit Suit value of the card -> Clubs, Diamonds, Hearts, or Spades
     * @param cardImage Image to be used for the card
     */
    public Card(Face face, Suit suit, ImageIcon cardImage) {
    	this.cardImage = cardImage;
    	this.face = face;
    	this.suit = suit;
    }
    
    /**
     * Getter for card's image
     * @return Image used for this card
     */
    public ImageIcon getCardImage() {
    	return cardImage;
    }
 
    /**
     * Getter for card's face
     * @return Face for this card
     */
    public Face face() {
        return face;
    }
 
    /**
     * Getter for the card's suit
     * @return Suit for this card
     */
    public Suit suit() {
        return suit;
    }
    
    /**
     * Getter for the card's numeric face value
     * @return Int for the Card's numeric face value -> 2-14
     */
    public int value() {
    	return face.value();
    }
 
    /**
     * Override the toString() method for objects to return a
     * human friendly String containing the face and suit of the card
     * @return String containing the card's face and suit
     */
    @Override
    public String toString() {
        return face + " of " + suit;
    }

    /**
     * Override the compareTo() method for comparable objects to compare
     * the numeric face value (2-14) of this card and a given card
     * @param Card to which this card should be compared
     * @return 0 if this card has the same numeric face value as the
     * given card, a positive integer representing the difference if this card's 
     * numeric face value is larger than the given card, or a negative integer
     * representing the difference if this card's numeric face value is less
     * than that of the given card.
     */
	@Override
	public int compareTo(Card otherCard) {
		return this.value() - otherCard.value();
	}
}
